import useServer from "server";
import { ProjectType } from "types";
import { useMutation, useQueryClient } from "react-query";

export const useAddProject = () => {
  const client = useServer();
  const queryClient = useQueryClient();

  return useMutation(
    (params: Partial<ProjectType>) => {
      return client("projects", { data: params, method: "POST" });
    },
    { onSuccess: () => queryClient.invalidateQueries("projects") }
  );
};
